// pages/about/about.js
var until = require("../../utils/util")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    top: 0,
    editstatus: true,
    markers: [{
      id: 0,
      latitude: 23.099994,
      longitude: 113.324520,
      width: 20,
      height: 20
    }],
    user1top:"某某集团董事长",
    user1btn:"张三",
    servicetoptext:'意音文字是由表义的象形符号和表音的声旁组成的文字，汉字是由表形文字进化成的意音文字，汉字也是语素文字。意音文字是由表义',
    fileList1: '',
    fileList2: '',
    fileList3: '',
    fileList4: '',
    fileList5: '',
    imglist:[],
    information:''
  },
  //背景图
  banner() {
    var that = this;
    wx.chooseImage({
      sizeType:["original","compressed"],
      success (res) {
        const tempFilePaths = res.tempFilePaths
        that.setData({
          imglist:that.data.imglist.concat(tempFilePaths)
        })
      }
    })
  },
  // 编辑
  change() {
    this.setData({editstatus: false})
  },
  //关闭
  formReset(e) {
    console.log('form发生了reset事件，携带数据为：', e.detail.value)
    console.log(this.data.imglist)
    this.setData({editstatus: true})
    // this.setData({
    //   chosen: ''
    // })
  },
  //确定
  formSubmit(e) {
    console.log(e.detail)
    this.setData({editstatus: true})
    // console.log(this.data.information)
  },
  Read1(event){
    var that = this;
    wx.chooseImage({
      sizeType:["original","compressed"],
      sourceType:["album","camera"],
      success (res) {
        const tempFilePaths = res.tempFilePaths
        that.setData({
          // imglist:that.data.imglist.concat(tempFilePaths)
          fileList1:tempFilePaths
        })
      }
    })
  },
  Read2(event){
    var that = this;
    wx.chooseImage({
      sizeType:["original","compressed"],
      sourceType:["album","camera"],
      success (res) {
        const tempFilePaths = res.tempFilePaths
        that.setData({
          // imglist:that.data.imglist.concat(tempFilePaths)
          fileList2:tempFilePaths
        })
      }
    })
  },
  Read3(event){
    var that = this;
    wx.chooseImage({
      sizeType:["original","compressed"],
      sourceType:["album","camera"],
      success (res) {
        const tempFilePaths = res.tempFilePaths
        that.setData({
          // imglist:that.data.imglist.concat(tempFilePaths)
          fileList3:tempFilePaths
        })
      }
    })
  },
  Read4(event){
    var that = this;
    wx.chooseImage({
      sizeType:["original","compressed"],
      sourceType:["album","camera"],
      success (res) {
        const tempFilePaths = res.tempFilePaths
        that.setData({
          // imglist:that.data.imglist.concat(tempFilePaths)
          fileList4:tempFilePaths
        })
      }
    })
  },
  Read5(event){
    var that = this;
    wx.chooseImage({
      sizeType:["original","compressed"],
      sourceType:["album","camera"],
      success (res) {
        const tempFilePaths = res.tempFilePaths
        that.setData({
          // imglist:that.data.imglist.concat(tempFilePaths)
          fileList5:tempFilePaths
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  // 监听滚动事件   scrollTop 滚动的距离
  onPageScroll: function (e) { // 获取滚动条当前位置
    // console.log(e)
    this.setData({
      top: e.scrollTop
    })
    if (e.scrollTop > this.data.tabScrollTop) {
      this.setData({
        tabFixed: true
      })
      // console.log("我锁定了")
    } else {
      this.setData({
        tabFixed: false
      })
    }
  },
  //点击跳转到板块一
  toblock1: function () {
    wx.pageScrollTo({
      /*
       *多减50是因为我的导航是悬浮的，会挡住部分内容
       *这里是1等于2rpx
       */
      scrollTop: this.data.block1_ScrollTop - 50
    })
  },
  //点击跳转到板块二
  toblock2: function () {
    wx.pageScrollTo({
      scrollTop: this.data.block2_ScrollTop - 50
    })
  },
  //点击跳转到板块三
  toblock3: function () {
    wx.pageScrollTo({
      scrollTop: this.data.block3_ScrollTop - 50
    })
  },
  //点击跳转到板块三
  toblock4: function () {
    wx.pageScrollTo({
      scrollTop: this.data.block4_ScrollTop - 50
    })
  },
  onLoad() {
    let that = this
    //  高度自适应
    wx.getSystemInfo({
      success: function (res) {
        var clientHeight = res.windowHeight,
          clientWidth = res.windowWidth,
          rpxR = 750 / clientWidth;
        var calc = clientHeight * rpxR;
        that.setData({
          winHeight: calc
        });
      }
    });
    var query = wx.createSelectorQuery()
    //获取顶部的距离
    query.select('#tab-con').boundingClientRect(function (res) {
      var top = res.top;
      if (top == null) {
        var top = 0;
      }
      that.setData({
        tabScrollTop: top
      })
    }).exec()
    //获取板块一离顶部的距离
    query.select('.block_1').boundingClientRect(function (res) {
      that.setData({
        block_1ScrollTop: res.top
      })
    }).exec()
    //获取板块二离顶部的距离
    query.select('.block_2').boundingClientRect(function (res) {
      that.setData({
        block2_ScrollTop: res.top
      })
    }).exec()
    //获取板块三离顶部的距离
    query.select('.block_3').boundingClientRect(function (res) {
      that.setData({
        block3_ScrollTop: res.top
      })
    }).exec()
    //获取板块四离顶部的距离
    query.select('.block_4').boundingClientRect(function (res) {
      that.setData({
        block4_ScrollTop: res.top
      })
    }).exec()
  },
  onShow() {

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

 
})